<?php
// Define path to application directory
defined('PROJECT_ROOT') ||
define('PROJECT_ROOT', realpath(dirname(__FILE__)));

defined('APPLICATION_PATH') ||
 define('APPLICATION_PATH', PROJECT_ROOT . '/application');
 
 // Define application environment
defined('APPLICATION_ENV') || define(
	'APPLICATION_ENV', 
    (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')
);

//是否开启css调试模式
defined('APPLICATION_DEBUG') ||
 define('APPLICATION_DEBUG', false);
 
//是否开启cdn加速
defined('CDN_SWITCH') ||
 define('CDN_SWITCH', true);
 
defined('APPLICATION_CONFIG_PATH') ||
 define('APPLICATION_CONFIG_PATH', APPLICATION_PATH . '/configs/');

$path = '';
defined('APPLICATION_PUBLIC') ||
 define('APPLICATION_PUBLIC', $path . '/public');
 
defined('CSS_SOURCE_PATH') ||
 define('CSS_SOURCE_PATH', APPLICATION_PUBLIC . '/css/source');
 
defined('CSS_MIN_PATH') ||
 define('CSS_MIN_PATH', APPLICATION_PUBLIC . '/css/sourc_bak');
 
defined('APPLICATION_URL') ||
 define('APPLICATION_URL', $path);
// Ensure library/ is on include_path
set_include_path(
    implode(
        PATH_SEPARATOR, 
        array(realpath(APPLICATION_PATH . '/../library'), 
        realpath(APPLICATION_PATH . '/models'),
        get_include_path())
    )
);
//Set timezone
date_default_timezone_set('Asia/Shanghai');
//Register configs
require_once 'Zend/Registry.php';
require_once "Zend/Config/Ini.php";
$configs = array(
    'db' => APPLICATION_CONFIG_PATH . 'db.ini',
	'config' => APPLICATION_CONFIG_PATH . 'config.ini',
	'database' => APPLICATION_CONFIG_PATH . 'database.ini'
);
foreach ($configs as $key => $configPath) {
    $config = new Zend_Config_Ini($configPath, APPLICATION_ENV);
    $registry = Zend_Registry::getInstance()->set($key, $config);
}

/** Zend_Application */
require_once 'Zend/Application.php';
require_once "Zend/Loader/Autoloader.php";
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV, 
    APPLICATION_CONFIG_PATH . '/application.ini'
);
//$FrontController = Zend_Controller_Front::getInstance();
$application->bootstrap()->run();
